//
//  ViewController.m
//  ContronFun
//
//  Created by student on 16/2/18.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)sliderChanged:(UISlider *)sender
{
    //滑动条的值 value属性
    int value = sender.value;
    //把滑动条的值显示到Lable上
    self.sliderValueLable.text = [NSString stringWithFormat:@"%i",value];
    
}

//分段控件改变触发的方法
- (IBAction)segementChanged:(UISegmentedControl *)sender
{
    //分段控件的主要属性
    //当前选中项 sender.selectedSegmentIndex
    
    //1 如果是点开关段
    //显示开关，隐藏按钮
    //2 如果是点按钮段
    //相反
    if(sender.selectedSegmentIndex == 0)
    {
        self.leftSwith.hidden = NO;
        self.rightSwith.hidden = NO;
        self.doSomethingBtn.hidden = YES;
    }
    else
    {
        self.leftSwith.hidden = YES;
        self.rightSwith.hidden = YES;
        self.doSomethingBtn.hidden = NO;
        
    }
}

- (IBAction)swithChanged:(UISwitch *)sender
{
    //开关控件的主要属性
    //开关的当前开关状态 on属性
    BOOL open = sender.on;
    //设置状态，并是否要带上动画
    [self.leftSwith setOn:open animated:YES];
    [self.rightSwith setOn:open animated:NO];
}

- (IBAction)doSomethingBtnPressed:(UIButton *)sender
{
UIActionSheet *sheet = [[UIActionSheet alloc]initWithTitle:@"你确定吗？"delegate:self cancelButtonTitle:@"取消"destructiveButtonTitle:@"是的，我确定！" otherButtonTitles: nil];
    [sheet showInView:self.view];
}
#pragma mark - UIAlerViewDelegate Method 弹出框的代理方法
-(void)actionSheet:(UIActionSheet *)actionSheet
        clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(buttonIndex == actionSheet.destructiveButtonIndex)
    {
        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"某些事项呗执行了" message:[NSString stringWithFormat:@"%@,easy,一切都正常运行了",_nameTextFileId.text] delegate:self cancelButtonTitle:@"阿西吧" otherButtonTitles: nil];
        [alertView show];
    }
}
- (IBAction)backTap:(id)sender
{
    // 两种方法都可以
    // 1. 当前视图结束编辑状态
    //    [self.view endEditing:YES];
    
    // 2. 文本框取消第一响应者
    [self.nameTextFileId resignFirstResponder];
    [self.phoneTextFileId resignFirstResponder];

}


@end
